home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <memory.h>
- #include <process.h>
- #define CONTROL 0x34
- #define CONT2 0xb4
- int inport, *storage[6];
- char *malloc();
- unsigned prt0,cntrlpt,prt1,prt2;
- int prime,count,i,iter,y[50],baseio,seg320;
- char name[20],buffer[24];
- FILE *fp;
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int k,value;
- unsigned div;
- long count;
- float trate,osc,rate;
- for (k=0;k<6;k++) storage[k]=(int *)malloc(0x8000);
- baseio=0x300;
- i=2;
- osc = 5.0;
- if (i == 2)
- osc = 6.25;
- printf("Clock input = %f Mhz\n",osc);
- osc = osc * 1.0e6;
- cntrlpt = baseio + 7;
- prt0 = baseio + 4;
- prt2 = baseio + 6;
- inp(cntrlpt); /* halt */
- spawnl(P_WAIT,"intel",argv[0],"gather","d000","300","0",NULL);
- clark: do {
- printf("Input desired sample rate in Hz ");
- scanf( "%f",&rate);
- } while ( (rate < 80.0 ) || (rate > 40000.1));
- /* count gives you the oscillator "divisor" just as in SIO's */
- count = osc/rate;
- if ( count < 2 ) count += 1;
- trate = osc /(float)count;
- printf("\nRate = %f ",trate);
- /* set timers for desired sampling rate */
- control_timer(count,osc,&trate);
- seg320=0xD000;
- printf("\nDestination File Name ? ");
- scanf("%s",name);
- if( (fp =fopen(name,"wb")) == NULL ) {
- printf("file open error\n");
- exit();
- }
- inp(cntrlpt);
- printf("\nHit any character when ready");
- /* routine to check for a keyboard strike and to eat that char */
- ci();
- inp(prt2);
- for(k=0;k<6;k++) {
- fulbuf(baseio,k); /* read in data from 320 */
- }
- inp(cntrlpt);
- for (k=0;k<6;k++) fwrite(storage[k],2,0x4000,fp);
- fclose(fp);
- }
-
- control_timer(cnt,osc,trate)
- long cnt;
- float *trate,osc;
- {
- int ctl,cth;
- /* tell board timer info coming */
- outp(cntrlpt ,CONTROL);
- /* count is timing divisor */
- ctl = cnt & 0xff; /* lo byte */
- cth = ( cnt >> 8 ) & 0xff;/* hi byte */
- /* control timer 0 */
- outp(prt0 , ctl);
- outp(prt0 , cth);
- /* control timer 2 */
- outp(cntrlpt , CONT2);
- outp(prt2 , ctl);
- outp(prt2 , cth);
- /* compute new sampling rate for output on screen*/
- *trate = osc/(float)cnt;
- }
-
- ci()
- {
- int kbhit(),getch(),j;
- while (kbhit()==0) {};
- j=getch();
- }
-
- fulbuf(baseio,which)
- int baseio,which;
- {
- int i,j,porti;
- j=-1;
- porti=baseio+4;
- for(i=0;i<0x4000;i++) {
- while(inp(baseio+4)==j) {};
- j=inp(porti);
- *(storage[which]+i)=(inp(baseio+1)<<8)+inp(baseio);
- }
- }
-